﻿<!DOCTYPE html>
<html lang="en">
<head>
    <%- include('includes/head',{title:'All Posts' }) %>
    <link rel="stylesheet" href="/styles/posts.css">
</head>
<body>
<%- include('includes/header') %>
<main id="all-posts">
    <h1>All Posts</h1>
    <% if(!posts || posts.length === 0){ %>
        <p>No posts found - maybe start creating some?</p>
        <a class="btn" href="/new-post">Create a new post</a>
    <% } else { %>
        <ol id="posts-list">
            <% for(const post of posts){ %>
                <li>
                    <%- include('includes/post-item',{ post:post }) %>
                </li>
            <% } %>
        </ol>
    <% } %>
</main>
</body>
</html>